home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 34.zip
/
BS1 part 34
/
FredFish PD 319.adf
/
CNewsSrc
/
cnews.src.lzh
/
libcnews
/
time.c
< prev
Wrap
C/C++ Source or Header
|
1989-07-13
|
914b
|
42 lines
/*
* time utilities
*/
#include <stdio.h>
#include <sys/types.h>
#ifndef AMIGA
# include <sys/timeb.h> /* Amiga's is in libc.h */
#endif /* !AMIGA */
#include "libc.h"
#include "news.h"
/*
* Write a timestamp of the form "Jun 12 12:34:56.789" on fp.
* N.B.: no trailing newline is written.
*/
void timestamp(fp, timep)
FILE *fp;
time_t *timep; /* if non-null, return time() here for later use */
{
#ifdef AMIGA
time_t time_now;
(void) time(&time_now);
(void) fprintf(fp, "%.15s.000", ctime(&time_now) + 4);
if (timep != NULL)
*timep = time_now;
#else
struct timeb ftnow;
char ms[4]; /* room for "123" and a NUL */
ftime(&ftnow);
if (timep != NULL)
*timep = ftnow.time;
/* .15 excludes yyyy\n\0; + 4 omits day-of-week */
(void) fprintf(fp, "%.15s.", ctime(&ftnow.time) + 4);
(void) ltoza(ms, (long)ftnow.millitm, 3); /* 3 digits of output */
(void) fputs(ms, fp);
#endif /* AMIGA */
}